<template>
<div class="top">
    <div class="nav">
    <div class="logo"><img src="@/assets/images/icon.svg" alt=""></div>
    <div class="nav-w">
      <!-- active 里面为true就添加类为false就隐藏 -->
     <router-link to="/home"><div>首页</div></router-link>
     <router-link to="/songmore"><div>歌单</div></router-link>
     <router-link to="/rankingmore"><div>排行榜</div></router-link>
     <router-link to="/mvmore"><div>MV</div></router-link>
     <router-link to="/singermore"><div>歌手</div></router-link>
     <router-link to="/mymusic"><div>我的音乐</div></router-link>
    </div>
    <div class="search">
      <span class="iconfont icon-sousuo"></span>
      <input type="text" placeholder="搜索歌名" v-model="keyword" @keyup.enter="handleKey()">
    </div>
    <div class="login">
      <img src="@/assets/images/2.png" alt="">
      <div class="box">
        <div><a href="/mymusic">我的音乐</a></div>
        <div @click="handleback"><a href="##">退出登录</a></div>
      </div>
    </div>
  </div>
</div>
</template>

<script>
export default {
  data(){
    return{
      keyword:""
    }
  },
  methods:{
    change(index){
      console.log(index);
      this.current = index
    },
    handleKey(){
      console.log(this.keyword);
      let val = this.keyword
      this.$router.push(`/search?key=${val}`)
      this.keyword = ""
    },
    handleback(){
      this.$cookie.delete("token")
      this.$router.push("/login")
    }
  }
};
</script>

<style scoped>
.top {
  height: 70px;
  background-color: #abc4ff;
  box-shadow: 7px -3px 4px 8px #96bbbb;
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 1200px;
  margin: 0 auto;
}
.logo img {
  height: 50px;
}
.nav-w {
  display: flex;
  align-items: center;
  height: 70px;
}
.nav-w>a {
  padding: 0 50px;
  /* margin: 0 25px; */
  line-height: 70px;
}
.nav-w>a:hover {
  background-color: #9BB1FF;
}
.search{
  position: relative;
}
.search input {
  height: 30px;
  border-radius: 15px;
  border: none;
  outline: none;
  text-indent: 28px;
}
.search .icon-sousuo{
  position: absolute;
  top: 8px;
  left: 10px;
}
.login {
  position: relative;
}
.login img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
}
.router-link-active {
    color: #fff;
    background-color: #9BB1FF;
}
.box {
  text-align: center;
  width: 100px;
  left: -15px;
  top: 60px;
  position: absolute;
  z-index: 999;
  background-color: #9BB1FF;
  display: none;
}
.box >div {
  line-height: 30px;
}
.login:hover .box {
  display: block;
}
</style>